package com.aydqyy.springbootstart.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.aydqyy.springbootstart.dao.DeviceDao;
import com.aydqyy.springbootstart.entity.Device;
import com.aydqyy.springbootstart.service.DeviceService;
import org.springframework.stereotype.Service;

/**
 * (Device)表服务实现类
 *
 * @author makejava
 * @since 2025-03-20 11:24:00
 */
@Service("deviceService")
public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements DeviceService {
    public Page<Device> getDevicePage(int pageNum, int pageSize, String keyword) {
        Page<Device> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(Device::getName, keyword);  // 条件过滤
        wrapper.or().like(Device::getIp, keyword);  // 条件过滤
        wrapper.orderByDesc(Device::getId);  // 排序
        return baseMapper.selectPage(page, wrapper);
    }
}

